package com.xiaoran.client.config;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.xiaoran.client.channel.ProviderService;
import org.I0Itec.zkclient.ZkClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.security.Provider;
import java.security.ProviderException;
import java.util.Calendar;
import java.util.List;

@Configuration
public class BeanConfig {

    private static final int EXPIRE_SECONDS = 86400;

    @Resource
    private ClientValue clientValue;

    @Bean
    public ZkClient zkClient() {
        return new ZkClient(clientValue.getZkAddr(), clientValue.getConnectTimeout());
    }


    @Bean
    public LoadingCache<String, List<ProviderService>> buildCache() {
        return CacheBuilder.newBuilder().build(new CacheLoader<String, List<ProviderService>>() {
            @Override
            public List<ProviderService> load(String key) throws Exception {
                return null;
            }
        });
    }
}
